<template>
  <div>
    <div style="display: flex; justify-content: flex-start">
      <el-input
        placeholder="档案号/姓名"
        v-model="page.searchObj.query"
        autofocus
        style="width: 230px; margin-right: 30px"
        clearable
        ><i slot="prefix" class="el-input__icon el-icon-search"></i
      ></el-input>
      <el-button
        type="primary"
        icon="el-icon-search"
        @click="queryTInterposeFollowupVisitAll"
        >搜索</el-button
      >
    </div>
    <el-button
      type="primary"
      style="display: flex; justify-content: flex-start; margin: 10px 0"
      @click="show"
      >新增</el-button
    >
    <el-table
      :data="tableData"
      style="width: 100%"
      height="65vh"
      highlight-current-row
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="return_time" label="回访日期"> </el-table-column>
      <el-table-column prop="interpose_name" label="被干预人">
      </el-table-column>
      <el-table-column prop="user_name" label="回访人员"> </el-table-column>
      <el-table-column prop="visit_method" label="联系方式"> </el-table-column>
      <el-table-column prop="return_content" label="回访内容">
      </el-table-column>
      <el-table-column prop="feedback_info" label="反馈信息"> </el-table-column>
      <el-table-column prop="handling_result" label="处理结果">
      </el-table-column>
      
      <el-table-column label="操作">
        <template slot-scope="">
          <span>
            <el-button type="primary" icon="el-icon-edit" circle></el-button>
          </span>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.pageNum"
        :page-sizes="[5, 10]"
        :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
    <el-dialog title="新增" :visible.sync="dialogTableVisible" width="70%">
      <el-tabs stretch type="border-card">
        <el-tab-pane label="基本信息" >
          <el-form
            ref="numberValidateForm"
            label-width="100px"
            class="demo-ruleForm"
          >
            <div style="display: flex; justify-content: space-around">
              <div>
                <el-form-item label="被干预人员">
                  <el-select
                    v-model="value"
                    clearable
                    placeholder="请选择被干预人员"
                    @change="check"
                  >
                    <el-option
                      v-for="item in options"
                      :key="item.rid"
                      :label="item.name"
                      :value="item.rid"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
              <div>
                <el-form-item label="档案号">
                  <el-input autocomplete="off" v-model="interposeFollowupVisit.fileNumber" readonly></el-input>
                </el-form-item>
              </div>
            </div>
            <div style="display: flex; justify-content: space-around">
              <div>
                <el-form-item label="回访日期">
                  <el-date-picker
                    v-model="interposeFollowupVisit.return_time"
                    type="date"
                    placeholder="选择日期"
                    value-format="yyyy-MM-dd"
                  >
                  </el-date-picker>
                </el-form-item>
              </div>
              <div>
                <el-form-item label="具体时间">
                  <el-time-picker
                    v-model="interposeFollowupVisit.specific_time"
                    :picker-options="{
                      selectableRange: '18:30:00 - 20:30:00',
                    }"
                    placeholder="任意时间点"
                    value-format="HH:mm:ss"
                  >
                  </el-time-picker>
                </el-form-item>
              </div>
            </div>
            <div style="display: flex; justify-content: space-around">
              <div>
                <el-form-item label="方式">
                    <el-select
                    v-model="interposeFollowupVisit.visit_method"
                    clearable
                  >
                    <el-option
                      v-for="item in options2"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
              <div>
                <el-form-item label="健康管理师">
                    <el-select v-model="interposeFollowupVisit.health_mgr_id" placeholder="请选择活动区域">
                    <el-option :label="user.user_name" :value="user.id"></el-option>
                    </el-select>
                </el-form-item>
              </div>
            </div>
            <div>
              <el-form-item label="回访内容">
                <el-input type="textarea" rows="3" v-model="interposeFollowupVisit.return_content"></el-input>
              </el-form-item>
            </div>
            <div>
              <el-form-item label="反馈信息">
                <el-input type="textarea" rows="3" v-model="interposeFollowupVisit.feedback_info"></el-input>
              </el-form-item>
            </div>
            <div>
              <el-form-item label="处理结果">
                <el-input type="textarea" rows="3" v-model="interposeFollowupVisit.handling_result"></el-input>
              </el-form-item>
            </div>
          </el-form>
        </el-tab-pane>
      </el-tabs>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogTableVisible = false">取 消</el-button>
        <el-button type="primary" @click="save">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
  
  <script>
export default {
  data() {
    return {
      user:eval("(" + sessionStorage.getItem("userName") + ")") ,
      options: [],
      options2:[{value: "电话",label: "电话",},{value: "邮箱",label: "邮箱",},{value: "短信",label: "短信",},],
      value: "",
      dialogTableVisible: false,
      page: {
        //分页查询条件
        pageNum: 1, //当前页
        pageSize: 5, //页面数量
        searchObj: {
          //条件对象
          query: "", //姓名，手机号
        },
      },
      tableData: [], //表格数据
      total: 0, //总数量
      interposeFollowupVisit:{
        health_mgr_id:eval("(" + sessionStorage.getItem("userName") + ")").id,//健康管理师编号
        interpose_name:'',//被干预人
        fileNumber:'',//档案号
        return_time:'',//回访日期
        specific_time:new Date(2016, 9, 10, 18, 40),//具体时间
        visit_method:'电话',//联系方式
        return_content:'',//回访内容
        feedback_info:'',//反馈信息
        handling_result:'',//处理结果
        createtime:'',//创建时间
        updatetime:'',//修改时间
      }
    };
  },
  created() {
    this.queryTInterposeFollowupVisitAll();
    this.queryTInterposeSchemeAll();
  },
  methods: {
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.queryTInterposeFollowupVisitAll();
    },
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.queryTInterposeFollowupVisitAll();
    },
    //打开新增模态框
    show() {
      this.dialogTableVisible = true;
    },
    // 查询所有随访信息
    queryTInterposeFollowupVisitAll() {
      this.axios
        .post("/api/hj/queryTInterposeFollowupVisitAll", this.page)
        .then((result) => {
          this.total = result.data.total;
          this.tableData = result.data.list;
          console.log(result.data);
        });
    },
    //查询已干预的信息
    queryTInterposeSchemeAll(){
        this.axios
        .post("/api/hj/queryTInterposeSchemeAll", this.page)
        .then((result) => {
          this.options=result.data;
        });
    },
    check(){
        this.interposeFollowupVisit.fileNumber='';
        this.options.forEach(i=>{
            if(i.rid==this.value){
                this.interposeFollowupVisit.fileNumber=i.file_number;
                this.interposeFollowupVisit.interpose_name=i.name;
            }
        })
    },
    save(){
        let date = new Date();
        this.interposeFollowupVisit.createtime=date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
        this.interposeFollowupVisit.updatetime=date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
        this.axios
        .post("/api/hj/addTInterposeSchemeAll", this.interposeFollowupVisit)
        .then((result) => {
          if(result.data>0){
          this.$message({
                  showClose: true,
                  message: '成功操作一条数据',
                   type: 'success'
          });
          this.queryTInterposeFollowupVisitAll();
          this.dialogTableVisible=false;
        }
        });
    }
    
  },
};
</script>
  
  <style>
</style>